<?php
/**
 * Return property link to shared file folder.
 * Function autodetect file folder by file type.
 * @param asccos array: url => filename.filetype  
 */
 
 // TODO: Check, if current url is correct
 // TODO: If filetype directory exists 
 // TODO: Smarty exception parser, hov to do it ?
function    smarty_function_GetShared($params)
{
    if(!array_key_exists('url',$params)) die('SMARTY.GetShared: Unknown parameter!');
    
    $matched = array();        
    if(preg_match('/\.([a-zA-Z0-9]+)$/', $params['url'], $matched))
    {                                
        if($matched[1] == "png" || $matched[1]=="jpg")
        {
            $matched[1]="img";
        }
        return '/shared/'.$matched[1].'/'.$params['url'];
    }else
        die('SMARTY.GetShared: Unknown filetype');    
}
?>